package com.example.daxiguaforharmony.game.core.featrue;

import java.util.ArrayList;
import java.util.List;

public class Featrue {
    private List<IInitializeSystem> _inittializeSystems = new ArrayList<IInitializeSystem>();
    private List<IReactiveSystem> _reactiveSystems = new ArrayList<IReactiveSystem>();

    public void Startup() {

    }

    public void Update(float dt) {

    }

    public void Destory() {

    }

    public void AddSystem(ISystem system) {
        if (system instanceof IInitializeSystem) {
            this._inittializeSystems.add((IInitializeSystem)system);
        } else if (system instanceof IReactiveSystem) {
            this._reactiveSystems.add((IReactiveSystem)system);
        }
    }

    public void RemoveSystem(ISystem system) {
        if (system instanceof IInitializeSystem) {
            int f = this._inittializeSystems.indexOf((IInitializeSystem)system);
            if (f >= 0) this._inittializeSystems.remove(f);
        }
    }

    public void AddEvent(String type, Object arg1) {
        this.AddEvent(type, arg1, null, null, null, null);
    }

    public void AddEvent(String type, Object arg1, Object arg2) {
        this.AddEvent(type, arg1, arg2, null, null, null);
    }

    public void AddEvent(String type, Object arg1, Object arg2, Object arg3) {
        this.AddEvent(type, arg1, arg2, arg3, null, null);
    }

    public void AddEvent(String type, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
        for (int i = 0; i < this._reactiveSystems.size(); i++) {
            IReactiveSystem system = this._reactiveSystems.get(i);
            if (system.Filter(type)) {
                system.Execute(type, arg1, arg2, arg3, arg4, arg5);
            }
        }
        this.emit(type, arg1, arg2, arg3, arg4, arg5);
    }

    private void emit(String type, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {

    }
}
